package com.wxw.gulidemo.controller;

import com.wxw.gulidemo.R;
import com.wxw.gulidemo.service.IStatisticsDailyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;

import java.util.Map;

/**
 * <p>
 * 网站统计日数据 前端控制器
 * </p>
 *
 * @author xinxinzi
 * @since 2022-06-21
 */
@RestController
@CrossOrigin
@RequestMapping("/staService/daily")
public class StatisticsDailyController {

    @Autowired
    private IStatisticsDailyService statisticsDailyService;

    //根据日期统计注册人数
    @PostMapping("/createStatisticsByDay/{day}")
    public R createStatisticsByDay(@PathVariable String day){
        statisticsDailyService.createStatisticsByDay(day);
        return R.ok();
    }

    //图表显示，返回两部分数据，日期json数组，数量json数组
    @GetMapping("/showData/{type}/{begin}/{end}")
    public R showData(@PathVariable String type,
                      @PathVariable String begin,
                      @PathVariable String end){

        Map<String,Object> map = statisticsDailyService.getShowData(type,begin,end);
        return R.ok().data(map);
    }


}
